import pika, sys

credentials = pika.PlainCredentials("guest", "guest")
conn_params = pika.ConnectionParameters("localhost",credentials=credentials)
conn_broker = pika.BlockingConnection(conn_params)
channel = conn_broker.channel()

def msg_consumer(channel, method, header, body):
    channel.basic_ack(delivery_tag=method.delivery_tag) 
    if body == "quit":
        channel.basic_cancel(consumer_tag="hello-consumer") 
        channel.stop_consuming()
    else:
        print body+str(method.delivery_tag)
    return
channel.basic_consume(msg_consumer,queue="queue0",consumer_tag="hello-consumer")
channel.start_consuming() 
